<template>
  <a-modal
    title="详情"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
  >
    <a-spin :spinning="confirmLoading">
      <a-row>
        <a-col :span="24"><h3>{{ data.roomName}}</h3></a-col>
      </a-row>
       <a-row>
        <a-col :span="24">單號：{{ data.no}}</a-col>
        <a-col :span="24">來源：  {{ 'bill_water_source' | dictType(data.source) }}</a-col>
        <a-col :span="24">交易日期：{{ data.receiveDate}}</a-col>
        <a-col :span="24">交易方式：{{ statusFkfsFilter(data.transaction) }}</a-col>
      </a-row>
      <a-divider />
      <a-row>
        <a-col :span="24"><h3>費用明細</h3></a-col>
      </a-row>
      <a-row>
        <a-col :span="24" v-for="(item,index) in data.detailList" :key="index">
          {{ item.name }}：{{ item.amount }}元
        </a-col>
        <a-col :span="24"><h3>合計：{{ data.amount }}元</h3></a-col>
      </a-row>
      <a-divider />
      <a-row>
        <a-col :span="24">經辦人：{{ data.manager }}</a-col>
        <a-col :span="24">操作時間：{{ data.managertTime }}</a-col>
        <a-col :span="24">審核標志：{{ data.auditFlag === 0 ? '未審核' : '已審核' }}</a-col>
        <a-col :span="24">審核人：{{ data.auditName }}</a-col>
        <a-col :span="24">審核時間：{{ data.auditTime }}</a-col>
      </a-row>
    </a-spin>
  </a-modal>
</template>

<script>
  import moment from 'moment'
  import { getBillWaterDetail } from '@/api/modular/main/billwater/billWaterManage'
  import { busMeansOfTransactionList } from '@/api/modular/main/busmeansoftransaction/busMeansOfTransactionManage'
  export default {
    data () {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
        sourceData: [],
        transactionData: [],
        auditFlagData: [],
        auditTimeDateString: '',
        visible: false,
        confirmLoading: false,
        data: {}
      }
    },
    methods: {
      moment,
      // 初始化方法
      edit (id) {
        this.initData(id)
        this.visible = true
        const sourceOption = this.$options
        this.sourceData = sourceOption.filters['dictData']('bill_water_source')
      },
      initData(id) {
         getBillWaterDetail(id).then((res) => {
          if (res.code === 200) {
            this.data = res.data
          } else {
            this.$message.error(res.msg)
          }
        })
        busMeansOfTransactionList().then((res) => {
          if (res.code === 200) {
            this.transactionData = res.data
          } else {
            this.$message.error(res.msg)
          }
        })
      },
      statusFkfsFilter (id) {
        // eslint-disable-next-line eqeqeq
        const values = this.transactionData.filter(item => item.id == id)
        if (values.length > 0) {
          return values[0].name
        }
      },
      handleSubmit () {
        this.handleCancel()
      },
      handleCancel () {
        this.visible = false
        this.data = {}
      }
    }
  }
</script>
